package cn.xiaolongyuan.spring.cloud.swagger2;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.cloud.client.SpringCloudApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.client.RestTemplate;

/**
 * Zuul 网关
 */
@SpringCloudApplication
@EnableZuulProxy
@EnableScheduling
@EnableFeignClients
@Slf4j
public class Swagger2GatewayApplication implements CommandLineRunner {

    public static void main(String[] args) {
        SpringApplication.run(Swagger2GatewayApplication.class, args);
    }

    @Override
    public void run(String... strings) throws Exception {
    }

    @Bean
    @LoadBalanced
    RestTemplate serviceRestTemplate(){
        return new RestTemplateBuilder()
//                .setConnectTimeout(3000)
//                .setReadTimeout(3000)
                .build();
    }

}
